//
//  NFirstLoginSetViewController.m
//  News
//
//  Created by zhangtao on 2018/11/5.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "NFirstLoginSetViewController.h"
#import "NLoginChooseThemeViewController.h"
#import "NImagePickerControl.h"
#import "LCIPAddress.h"

@interface NFirstLoginSetViewController ()
@property (weak, nonatomic) IBOutlet UIView *mainView;
@property (weak, nonatomic) IBOutlet UIButton *headImgBtn;
@property (weak, nonatomic) IBOutlet UITextField *nickNameTF;
@property (weak, nonatomic) IBOutlet UITextField *signName;

@end

@implementation NFirstLoginSetViewController

-(void)viewDidLayoutSubviews{
    _mainView.frame = CGRectMake(0, navHeight-64+15, ACEWidth, ACEHeight);
}
- (IBAction)back:(id)sender {
}

- (IBAction)changeHead:(UIButton *)sender {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:nil preferredStyle:UIAlertControllerStyleActionSheet];//修改头像
    
    UIAlertAction *camera = [UIAlertAction actionWithTitle:NSLocalizedString(@"相机", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NImagePickerControl *control = [[NImagePickerControl alloc]initWithController:self];
        control.imagePickerCallBack = ^(UIImage * _Nonnull image) {
            [self uploadImg:image];
        };
        [control camera];
        
    }];
    
    UIAlertAction *album = [UIAlertAction actionWithTitle:NSLocalizedString(@"相册", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NImagePickerControl *control = [[NImagePickerControl alloc]initWithController:self];
        control.imagePickerCallBack = ^(UIImage * _Nonnull image) {
            [self uploadImg:image];
        };
        [control album];
        
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"取消", nil) style:UIAlertActionStyleCancel handler:nil];
    
    [alert addAction:camera];
    [alert addAction:album];
    [alert addAction:cancel];
    
    [self presentViewController:alert animated:YES completion:nil];
    //    footerView.addOne = [UIImage imageNamed:@"add"];
}

-(void)uploadImg:(UIImage *)image{
    [_headImgBtn setImage:image forState:UIControlStateNormal];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)nextStep:(id)sender {
    NSString *ip = [LCIPAddress getIPAddress];
    NSDictionary *users = @{@"ID":@"0",
                            @"NickName":_nickNameTF.text,
                            @"RegIP":ip,
                            @"Tel":_phone,
                            
                            @"HeadPic":@"123.png",
                            @"Introduce":@"",
                            @"InviterID":@"",
                            
                            @"UserType":@"1",
                            @"FollowTopicalIDs":@"",
                            @"WeiXinCode":@"",
                            @"AliPayCode":@"",
                            @"RegistType":@"0",
                            @"SmsCode":_code,
                            @"Token":TOKEN
                            };
    
    NSDictionary *param = @{@"user":users};
    
    [[NHTTPManage shareInstance]afPOST:HTTP_REGIST andParam:param success:^(id  _Nonnull responseObject) {
        NSLog(@".");
    } failture:^(id  _Nonnull error) {
        NSLog(@".");
        
        
//        NLoginChooseThemeViewController *choose = [[NLoginChooseThemeViewController alloc]init];
//        [self presentViewController:choose animated:YES completion:nil];

    }];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
